<?php
namespace app\common\model;

use app\extra\ApiToken;
use app\extra\BaseModel;
use app\extra\DBCont;
use think\model\concern\SoftDelete;

class Advert extends BaseModel
{
    use \think\model\concern\SoftDelete;
    protected $deleteTime = 'delete_time';
    protected $auto = ['user_id'];
    public function setUserIdAttr(){
        return getUserID();
    }
//    use SoftDelete;
    public function getPublishDescAttr($value,$data)
    {
        return DBCont::getPublishStatus($data['publish']);
    }
    /*public function getPhotoLinkAttr($value){
        return added_domain($value);
    }*/
    /**
     * 添加额外参数
     * @param $item
     */
    public function setAddedField(&$item){
        // $item['public_desc'] = \app\extra\DBCont::getPublishStatus($item['publish']);
        $item['user_desc'] = model('Admin')->getUserName($item['user_id']);
    }
    // 图片地址
    public function setPhotoLinkAttr($value){
        return serializeByArray($value);
    }
    public function getPhotoLinkAttr($value){
        return unSerializeByJson($value);
    }

}